﻿@{
    ViewBag.Title = "List";
    Layout = "~/Views/Shared/Master_EasyUI.cshtml";
} 
<script src="~/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
    select {
        width: 150px;
        height: 24px;
    }

    input {
        width: 100px;
        height: 20px;
    }

    .paramcontent {
        font-size: 13px;
        padding-left: 30px;
        margin-bottom: 5px;
        padding: 5px;
        border: 1px solid #ddd;
    }
</style>
<div class="paramcontent">
    意向车型：
    <select id="CarModel">
        <option value="-1" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;------请选择------</option>
    </select>
    经销商：
    <select id="Dealer">
        <option value="-1" selected="selected">&nbsp;&nbsp;&nbsp;&nbsp;------请选择------</option>
    </select>
    &nbsp;从&nbsp;
    <input id="datefrom" class="Wdate" type="text" onfocus="WdatePicker({maxDate:'%y-%M-%d'})" />
    &nbsp;到&nbsp;
    <input id="dateto" class="Wdate" type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datefrom\')}',maxDate:'%y-%M-%d'})" />

    <button type="button" id="btnQuery">查询</button>
</div>
<div>
    <table id="tt" nowrap="false"></table>
</div>



<script type="text/javascript">


    $(function () {

        $.get('/Default/GetDealer', {}, function (res) {

            $.each(res, function (i, item) {

                $('#Dealer').append("<option value='" + item.dealerId + "'>" + item.dealerName + "</option>");
            });
        });
        $.get('/Default/GetMaterial', {}, function (res) {

            $.each(res, function (i, item) {

                $('#CarModel').append("<option value='" + item.groupId + "'>" + item.groupName + "</option>");
            });
        });

        $('#btnQuery').click(function () {

            var datefrom = $('#datefrom').val();
            var dateto = $('#dateto').val();
            var carmodel = $('#CarModel').val();
            var dealer = $('#Dealer').val();

            //if ((datefrom == "" && dateto != "") || (datefrom != "" && dateto == "")) {
            //    alert('请输入完整时间段！');
            //    return;
            //}

            $('#tt').datagrid({
                url: "/Default/GetList?datefrom=" + escape(datefrom) +
                    "&dateto=" + escape(dateto) +
                     "&carmodel=" + escape(carmodel) +
                     "&dealer=" + escape(dealer) +
                    "&t=" + new Date().getTime(), queryParams: { pageNumber: 1, pageSize: 10 }, method: "post"
            });

            $('#tt').datagrid("clearSelections");


        });

        $('#tt').datagrid({
            title: '数据信息',
            //url: "/Default/GetList?t=" + new Date().getTime(),
            height: 'auto',
            striped: true,
            //fitColumns: false,
            rownumbers: true,
            idField: 'ID',
            remoteSort: true,
            singleSelect: true,
            pageSize: 10,
            pagination: true,
            loadMsg: '数据加载中请稍后……',
            //onLoadError: function () { alert('数据导入出错啦~'); },
            columns: [[
                { field: 'Name', title: '姓名', align: 'left', width: 150 },
                { field: 'Phone', title: '联系方式', align: 'left', width: 150 },
                { field: 'Province', title: '省', align: 'left', width: 100 },
                { field: 'City', title: '市', align: 'left', width: 100 },
                { field: 'Town', title: '区', align: 'left', width: 100 },
                { field: 'dealerName', title: '经销商', align: 'left', width: 200 },
                { field: 'groupName', title: '车型', align: 'left', width: 150 },
                { field: 'CreateTime', title: '创建时间', align: 'left', width: 150 }
            ]]

        });

    });

</script>



